package com.transfer.service;

import java.util.Date;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.transaction.annotation.Transactional;

import com.staff.entity.Staff;
import com.transfer.entity.TitleAppoint;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations={
		"classpath:applicationContext-core.xml"
		,"classpath:applicationContext-jpa.xml"
})
@Transactional
public class TitleAppointText {
	@Autowired
	private ITitleAppointService titleAppointService;
	
	@Test
	@Rollback(value=false)
	public void save() {
		for (int i = 1; i <=20; i++) {
			Staff staff = new Staff();
			Date date = new Date();
			TitleAppoint titleAppoint = new TitleAppoint();
			
			staff.setStaffNum("15"+i);
			staff.setStaffName("关联人事调动"+i);
			titleAppoint.setStaffName("关联人事调动"+i);
			titleAppoint.setStaffNum("05"+i);
			titleAppoint.setAppointTitle("高级工程师");
			titleAppoint.setAppointDate(date);
			titleAppoint.setStaff(staff);
			
			titleAppointService.saveOrUpdate(titleAppoint);
		}
	}
	//@Test
	@Rollback(value=false)
	public void delete() {
		titleAppointService.delete(titleAppointService.findOne(1L));
	}
}
